package com.translate.web.service;

import java.math.BigDecimal;
import java.util.List;
import java.util.function.Function;

import com.translate.entity.IdAndRecommendName;
import com.translate.entity.Order;
import com.translate.entity.TeamAssoc;
import com.translate.entity.TeamInfo;
import com.translate.entity.User;
import com.basic.service.contract.IBaseService;
import com.page.PageResponseData;
import com.returns.value.ICodeAndData;
import com.translate.vo.contract.IFollowPersonVO;
import com.translate.vo.contract.IUserIdAndNameVO;
import com.translate.vo.contract.IUserVO;
import com.translate.web.param.contract.IIdAndUserIdParam;
import com.translate.web.param.contract.IJoinTeamParam;
import com.translate.web.param.contract.ILoginParam;
import com.translate.web.param.contract.ILoginParamBySms;
import com.translate.web.param.contract.IRegisterParamByPhone;
import com.translate.web.param.contract.IRetrievePassword;
import com.translate.web.param.contract.IRetrievePasswordEmail;
import com.translate.web.param.contract.ITeamAddBySearchParam;
import com.translate.web.param.contract.IUpdateEmailParam;
import com.translate.web.param.contract.IUpdatePasswordParam;
import com.translate.web.param.contract.IUserAddParam;
import com.translate.web.param.contract.IUserIdParam;
import com.translate.web.param.contract.IWithdrawalAddParam;

/**
 * 用户接口
 * @author 111
 *
 */
public interface IUserService extends IBaseService<User> {

	/**
	 * 加入团队
	 * @return
	 */
	public int joinTeam(IJoinTeamParam param);
	
	/**
	 * 兑换学术币
	 * @param param
	 * @return
	 */
	public int exchangeAcademicCoins(IWithdrawalAddParam param);
	
	
	/**
	 * 团队成员及申请成员数量
	 * @param teamId
	 * @return
	 */
	public List<TeamInfo> groupNumAndApplyNum(int teamId);
	
	  
    /**
     * 根据用户姓名获取用户ids
     * @return
     */
    List<User> getUserIdsBySearchName(String userName);
	
	
	/**
	 * 根据姓名获取userIds
	 * @return
	 */
	public List<User> getUserIdsByRealname(String realname);
	
	/**
	 * 统计数量
	 * @param <DATA>
	 * @param teamId
	 * @return
	 */
	<DATA> List<DATA> staticsTeamInfo(int teamId);
	
	
	/**
	 * 获取团队成员
	 * @param <VO>
	 * @param userId
	 * @return
	 */
	public <VO extends IUserVO> ICodeAndData<PageResponseData<VO>> getTeamList(IUserIdParam page, Class<VO> target);
	
	/**
	 * 获取待审核的团队成员
	 * @param <VO>
	 * @param userId
	 * @return
	 */
	<VO extends IUserVO> ICodeAndData<PageResponseData<VO>> applyForTeamList(IUserIdParam page, Class<VO> target);
	
	/**
	 * 通过
	 * @param param
	 * @return
	 */
	ICodeAndData<Integer> passThrough(IIdAndUserIdParam param);
	
	
	/**
	 * 拒绝 加入团队
	 * @param param
	 * @return
	 */
	ICodeAndData<Integer> refuse(IIdAndUserIdParam param);
	
	/**
	 * 更新密码
	 * @param param
	 * @return
	 */
	ICodeAndData<Integer> updatePassword(IUpdatePasswordParam param);
	
	/**
	 * 移除团队
	 * @param param
	 * @return
	 */
	ICodeAndData<Integer> removeMemberByTeam(IIdAndUserIdParam param);
	
	
	/**
	 * 移除团队成员
	 * @param param
	 * @return
	 */
	ICodeAndData<Integer> addTeamMember(ITeamAddBySearchParam param);
	
	
	/**
	 * 退出团队
	 * @param param
	 * @return
	 */
	ICodeAndData<Integer> exitTeam(int id);
	
	
	/**
	 * @param <T> 返回类型
	 * @param <V> 第三方接口返回数据
	 * @param targetClass
	 * @param responseClass
	 * @return
	 */
	public boolean checkUserExits(String account);
	
	/**
	 * 跟进人列表
	 * @param <VO>
	 * @param customerId
	 * @param target
	 * @return
	 */
	<VO extends IFollowPersonVO> List<VO> getUserList(Integer[] customerId, Class<VO> target);
	
	public List<User> getDataByIdsMergeVO(Integer[] ids);
	
	public <VO extends IUserIdAndNameVO> List<VO> getDataByIdsMergeVO(Integer[] ids, Class<VO> target);
	
	public <VO> List<User> getDataByIdsMergeVO(List<VO> vos, Function<VO, Integer> function);
	
	
	/**
	 * 获取用户信息并缓存
	 * @param id
	 * @return
	 */
	public User getUserInfoToCache(int id);
	
	/**
     * 获取用户查重券
     * @param id
     * @return
     */
	User selectDuplicateCheckCoupon(int id);
	
	/**
	 * 更新折扣
	 * @param id
	 * @param reward
	 * @return
	 */
	int updateDiscount(long id, BigDecimal reward);	
	
	/**
	 * 统计推荐人数
	 * @param recommendId
	 * @return
	 */
	int countRecomendNum(long recommendId);
	
	/**
	 * 
	 * @param <VO>
	 * @param vos
	 * @param target
	 * @return
	 */
	<VO> List<VO> getUserList(List<VO> vos);
	
	/**
	 * 获取用户详情
	 * @param <VO>
	 * @param userId
	 * @param target
	 * @return
	 */
	<VO extends IUserVO> IUserVO getUserDetails(int userId, Class<VO> target);
	
	
	/**
	 * 根据模组用户id 获取数据
	 * @param <V>
	 * @param response
	 * @return
	 */
	public <V> V getUserInfoByModuleUserId(Class<V> targetClass, String userId);
	
	
	public User getUserInfoByModuleUserIdToRedis(String userId);

	
	
	/**
	 * 账号密码登录
	 * @param loginParam
	 * @return
	 */
	public ICodeAndData<User> loginByPwd(ILoginParam loginParam);
	
	
	public ICodeAndData<Integer> updateEmail(IUpdateEmailParam updateEmailParam);
	
	public ICodeAndData<Integer> checkEmail(IUpdateEmailParam updateEmailParam);
	
	/**
	 * 短信验证码登录
	 * @param loginParam
	 * @return
	 */
	public ICodeAndData<Number> loginBySms(ILoginParamBySms loginParam);
	
	/**
	 * 手机号注册
	 * @param loginParam
	 * @return
	 */
	public ICodeAndData<Number> registerByPhone(IRegisterParamByPhone loginParam);
	
	/**
	 * 邮箱注册
	 * @param loginParam
	 * @return
	 */
	public ICodeAndData<IdAndRecommendName> registerByEmail(IUserAddParam loginParam);
	
	/**
	 * 通过手机号找回密码
	 * @param loginParam
	 * @return
	 */
	public ICodeAndData<Number> retrievePasswordByPhone(IRetrievePassword loginParam);

	/**
	 * 通过邮箱找回密码
	 * @param paramByEmail
	 * @return
	 */
	public ICodeAndData<Number> retrievePasswordByEmail(IRetrievePasswordEmail paramByEmail);

	
	
	
	
	/**
	 * 团队数量
	 * @param teamIds
	 * @return
	 */
	public List<TeamAssoc> getTeamAssocs(int[] teamIds);

	/**
	 * 清理缓存
	 * @param userId
	 */
	void cleanCurrentUserCache(long userId);
	
}
